package com.example.designpatterns.observer;

public class WeatherDisplay implements Observer {
    private float temperature;
    private String name;
    // 新增：温度单位
    private String unit;

    public WeatherDisplay(String name, String unit) {
        this.name = name;
        this.unit = unit;
    }

    @Override
    public void update(float temperature) {
        this.temperature = temperature;
        display();
    }

    public void display() {
        System.out.println(name + "显示: 当前温度是 " + temperature + unit);
    }
}